/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SearchBillingMore.java
 *
 * Created on Aug 7, 2012, 2:41:26 PM
 */

package Model.dialog;

import DataBase.DBManagerment;
import Processing.PikaDate;
import java.sql.Connection;
import java.util.ArrayList;

/**
 *
 * @author Admin
 */
public class SearchReportMore extends javax.swing.JDialog {

    /** Creates new form SearchBillingMore */
    public SearchReportMore(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        conn = db.ConnectServer();
        cbbTest.setModel(db.getListTest(conn));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btgPaid = new javax.swing.ButtonGroup();
        pnlCenter = new javax.swing.JPanel();
        cbPatientID = new javax.swing.JCheckBox();
        cbDoctorID = new javax.swing.JCheckBox();
        cbTest = new javax.swing.JCheckBox();
        cbDateMade = new javax.swing.JCheckBox();
        txtPatientID = new javax.swing.JTextField();
        txtDoctorID = new javax.swing.JTextField();
        cbbDateMadeThan1 = new javax.swing.JComboBox();
        cbbDateMadeYear1 = new javax.swing.JComboBox();
        cbbDateMadeMonth1 = new javax.swing.JComboBox();
        cbbDateMadeDay1 = new javax.swing.JComboBox();
        cbbDateMadeThan2 = new javax.swing.JComboBox();
        cbbDateMadeDay2 = new javax.swing.JComboBox();
        cbbDateMadeMonth2 = new javax.swing.JComboBox();
        cbbDateMadeYear2 = new javax.swing.JComboBox();
        cbbTest = new javax.swing.JComboBox();
        pnlBootom = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Report Filter");
        setResizable(false);

        cbPatientID.setFont(new java.awt.Font("Tahoma", 1, 11));
        cbPatientID.setText("               Patient's ID:");
        cbPatientID.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                cbPatientIDStateChanged(evt);
            }
        });

        cbDoctorID.setFont(new java.awt.Font("Tahoma", 1, 11));
        cbDoctorID.setText("             Doctor's's ID:");
        cbDoctorID.setToolTipText("");
        cbDoctorID.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                cbDoctorIDStateChanged(evt);
            }
        });

        cbTest.setFont(new java.awt.Font("Tahoma", 1, 11));
        cbTest.setText("                            Test:");
        cbTest.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                cbTestStateChanged(evt);
            }
        });

        cbDateMade.setFont(new java.awt.Font("Tahoma", 1, 11));
        cbDateMade.setText("                 Date Made:");
        cbDateMade.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                cbDateMadeStateChanged(evt);
            }
        });

        txtPatientID.setEnabled(false);

        txtDoctorID.setEnabled(false);

        cbbDateMadeThan1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "=", ">", ">=", "<", "<=" }));
        cbbDateMadeThan1.setEnabled(false);
        cbbDateMadeThan1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeThan1ItemStateChanged(evt);
            }
        });

        cbbDateMadeYear1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023" }));
        cbbDateMadeYear1.setEnabled(false);
        cbbDateMadeYear1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeYear1ItemStateChanged(evt);
            }
        });

        cbbDateMadeMonth1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        cbbDateMadeMonth1.setEnabled(false);
        cbbDateMadeMonth1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeMonth1ItemStateChanged(evt);
            }
        });

        cbbDateMadeDay1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cbbDateMadeDay1.setEnabled(false);

        cbbDateMadeThan2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "No", "<", "<=" }));
        cbbDateMadeThan2.setEnabled(false);
        cbbDateMadeThan2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeThan2ItemStateChanged(evt);
            }
        });

        cbbDateMadeDay2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cbbDateMadeDay2.setEnabled(false);

        cbbDateMadeMonth2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        cbbDateMadeMonth2.setEnabled(false);
        cbbDateMadeMonth2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeMonth2ItemStateChanged(evt);
            }
        });

        cbbDateMadeYear2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023" }));
        cbbDateMadeYear2.setEnabled(false);
        cbbDateMadeYear2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbDateMadeYear2ItemStateChanged(evt);
            }
        });

        cbbTest.setEnabled(false);

        javax.swing.GroupLayout pnlCenterLayout = new javax.swing.GroupLayout(pnlCenter);
        pnlCenter.setLayout(pnlCenterLayout);
        pnlCenterLayout.setHorizontalGroup(
            pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCenterLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlCenterLayout.createSequentialGroup()
                        .addComponent(cbbDateMadeThan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cbbDateMadeYear2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbDateMadeMonth2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbDateMadeDay2, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlCenterLayout.createSequentialGroup()
                        .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlCenterLayout.createSequentialGroup()
                                .addComponent(cbPatientID)
                                .addGap(18, 18, 18)
                                .addComponent(txtPatientID, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))
                            .addGroup(pnlCenterLayout.createSequentialGroup()
                                .addComponent(cbDateMade)
                                .addGap(18, 18, 18)
                                .addComponent(cbbDateMadeThan1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(cbbDateMadeYear1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlCenterLayout.createSequentialGroup()
                                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbDoctorID)
                                    .addComponent(cbTest))
                                .addGap(18, 18, 18)
                                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbbTest, 0, 110, Short.MAX_VALUE)
                                    .addComponent(txtDoctorID, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbDateMadeMonth1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbbDateMadeDay1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(14, 14, 14))
        );
        pnlCenterLayout.setVerticalGroup(
            pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCenterLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbPatientID)
                    .addComponent(txtPatientID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbDoctorID)
                    .addComponent(txtDoctorID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbTest)
                    .addComponent(cbbTest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbDateMade)
                    .addComponent(cbbDateMadeThan1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeYear1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeMonth1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeDay1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbbDateMadeThan2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeYear2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeMonth2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbDateMadeDay2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        getContentPane().add(pnlCenter, java.awt.BorderLayout.LINE_END);

        pnlBootom.setPreferredSize(new java.awt.Dimension(400, 50));

        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBootomLayout = new javax.swing.GroupLayout(pnlBootom);
        pnlBootom.setLayout(pnlBootomLayout);
        pnlBootomLayout.setHorizontalGroup(
            pnlBootomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBootomLayout.createSequentialGroup()
                .addContainerGap(99, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addGap(137, 137, 137))
        );
        pnlBootomLayout.setVerticalGroup(
            pnlBootomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBootomLayout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(pnlBootomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        getContentPane().add(pnlBootom, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbPatientIDStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbPatientIDStateChanged
        // TODO add your handling code here:
        if (cbPatientID.isSelected()) {
            txtPatientID.setEnabled(true);
        }else{
            txtPatientID.setEnabled(false);
        }
    }//GEN-LAST:event_cbPatientIDStateChanged

    private void cbDoctorIDStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbDoctorIDStateChanged
        // TODO add your handling code here:
        if (cbDoctorID.isSelected()) {
            txtDoctorID.setEnabled(true);
        }else{
            txtDoctorID.setEnabled(false);
        }
    }//GEN-LAST:event_cbDoctorIDStateChanged

    private void cbTestStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbTestStateChanged
        // TODO add your handling code here:
        if (cbTest.isSelected()) {
            cbbTest.setEnabled(true);
        }else{
            cbbTest.setEnabled(false);
        }
    }//GEN-LAST:event_cbTestStateChanged

    private void cbDateMadeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbDateMadeStateChanged
        // TODO add your handling code here:
        if (cbDateMade.isSelected()) {
            cbbDateMadeThan1.setEnabled(true);
            cbbDateMadeYear1.setEnabled(true);
            cbbDateMadeMonth1.setEnabled(true);
            cbbDateMadeDay1.setEnabled(true);
        } else {
            cbbDateMadeThan1.setEnabled(false);
            cbbDateMadeYear1.setEnabled(false);
            cbbDateMadeMonth1.setEnabled(false);
            cbbDateMadeDay1.setEnabled(false);
            cbbDateMadeThan2.setEnabled(false);
            cbbDateMadeYear2.setEnabled(false);
            cbbDateMadeMonth2.setEnabled(false);
            cbbDateMadeDay2.setEnabled(false);
        }
    }//GEN-LAST:event_cbDateMadeStateChanged

    private void cbbDateMadeThan1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeThan1ItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (cbbDateMadeThan1.getSelectedItem().equals("=") || cbbDateMadeThan1.getSelectedItem().equals("<") || cbbDateMadeThan1.getSelectedItem().equals("<=")) {
                cbbDateMadeThan2.setEnabled(false);
                cbbDateMadeDay2.setEnabled(false);
                cbbDateMadeMonth2.setEnabled(false);
                cbbDateMadeYear2.setEnabled(false);
                cbbDateMadeThan2.setSelectedItem("No");
            }else{
                cbbDateMadeThan2.setEnabled(true);
            }
        }
    }//GEN-LAST:event_cbbDateMadeThan1ItemStateChanged

    private void cbbDateMadeThan2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeThan2ItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (cbbDateMadeThan2.getSelectedItem().equals("No")) {
                cbbDateMadeDay2.setEnabled(false);
                cbbDateMadeMonth2.setEnabled(false);
                cbbDateMadeYear2.setEnabled(false);
            }else{
                cbbDateMadeDay2.setEnabled(true);
                cbbDateMadeMonth2.setEnabled(true);
                cbbDateMadeYear2.setEnabled(true);
            }
        }
    }//GEN-LAST:event_cbbDateMadeThan2ItemStateChanged

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:\
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if(cbPatientID.isSelected()){
            String select = "[Patient's ID] = " + "'" + txtPatientID.getText() + "'";
            list.add(select);
        }

        if(cbDoctorID.isSelected()){
            String select = "[Doctor's ID] = " + "'" + txtDoctorID.getText() + "'";
            list.add(select);
        }

        if(cbTest.isSelected()){
            String select = "[Test's Name] = " + "'" + cbbTest.getSelectedItem().toString() + "'";
            list.add(select);
        }

        if(cbDateMade.isSelected()){
            if (cbbDateMadeThan1.getSelectedItem().equals("=")) {
                // Lấy một chuỗi dạng: "[Date Made] = '2012-7-8'" với ngày tháng lấy từ combobox
                String select = "[Date Made] = " + "'" + cbbDateMadeYear1.getSelectedItem().toString() + "-" + cbbDateMadeMonth1.getSelectedItem().toString() + "-" + cbbDateMadeDay1.getSelectedItem().toString() + "'";
                list.add(select);
            }else if (cbbDateMadeThan1.getSelectedItem().equals("<")) {
                // Lấy một chuỗi dạng: "[Date Made] < '2012-7-8'" với ngày tháng lấy từ combobox
                String select = "[Date Made] < " + "'" + cbbDateMadeYear1.getSelectedItem().toString() + "-" + cbbDateMadeMonth1.getSelectedItem().toString() + "-" + cbbDateMadeDay1.getSelectedItem().toString() + "'";
                list.add(select);
            }
            else if (cbbDateMadeThan1.getSelectedItem().equals("<=")) {
                // Lấy một chuỗi dạng: "[Date Made] <= '2012-7-8'" với ngày tháng lấy từ combobox
                String select = "[Date Made] <= " + "'" + cbbDateMadeYear1.getSelectedItem().toString() + "-" + cbbDateMadeMonth1.getSelectedItem().toString() + "-" + cbbDateMadeDay1.getSelectedItem().toString() + "'";
                list.add(select);
            }else if (cbbDateMadeThan1.getSelectedItem().equals(">")) {
                // Lấy một chuỗi dạng: "[Date Made] > '2012-7-8'" với ngày tháng lấy từ combobox
                String select = "[Date Made] > " + "'" + cbbDateMadeYear1.getSelectedItem().toString() + "-" + cbbDateMadeMonth1.getSelectedItem().toString() + "-" + cbbDateMadeDay1.getSelectedItem().toString() + "'";
                list.add(select);
                
                if (cbbDateMadeThan2.getSelectedItem().equals("<")) {
                    // Lấy một chuỗi dạng: "[Date Made] <= '2012-7-8'" với ngày tháng lấy từ combobox
                    String select2 = "[Date Made] < " + "'" + cbbDateMadeYear2.getSelectedItem().toString() + "-" + cbbDateMadeMonth2.getSelectedItem().toString() + "-" + cbbDateMadeDay2.getSelectedItem().toString() + "'";
                    list.add(select2);
                }else if (cbbDateMadeThan2.getSelectedItem().equals("<=")) {
                    // Lấy một chuỗi dạng: "[Date Made] <= '2012-7-8'" với ngày tháng lấy từ combobox
                    String select2 = "[Date Made] <= " + "'" + cbbDateMadeYear2.getSelectedItem().toString() + "-" + cbbDateMadeMonth2.getSelectedItem().toString() + "-" + cbbDateMadeDay2.getSelectedItem().toString() + "'";
                    list.add(select2);
                }
            }else if (cbbDateMadeThan1.getSelectedItem().equals(">=")) {
                // Lấy một chuỗi dạng: "[Date Made] > '2012-7-8'" với ngày tháng lấy từ combobox
                String select = "[Date Made] >= " + "'" + cbbDateMadeYear1.getSelectedItem().toString() + "-" + cbbDateMadeMonth1.getSelectedItem().toString() + "-" + cbbDateMadeDay1.getSelectedItem().toString() + "'";
                list.add(select);

                if (cbbDateMadeThan2.getSelectedItem().equals("<")) {
                    // Lấy một chuỗi dạng: "[Date Made] <= '2012-7-8'" với ngày tháng lấy từ combobox
                    String select2 = "[Date Made] < " + "'" + cbbDateMadeYear2.getSelectedItem().toString() + "-" + cbbDateMadeMonth2.getSelectedItem().toString() + "-" + cbbDateMadeDay2.getSelectedItem().toString() + "'";
                    list.add(select2);
                }else if (cbbDateMadeThan2.getSelectedItem().equals("<=")) {
                    // Lấy một chuỗi dạng: "[Date Made] <= '2012-7-8'" với ngày tháng lấy từ combobox
                    String select2 = "[Date Made] <= " + "'" + cbbDateMadeYear2.getSelectedItem().toString() + "-" + cbbDateMadeMonth2.getSelectedItem().toString() + "-" + cbbDateMadeDay2.getSelectedItem().toString() + "'";
                    list.add(select2);
                }
            }
        }

        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cbbDateMadeMonth1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeMonth1ItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbDateMadeMonth1.getSelectedItem().toString());
        int year = Integer.parseInt(cbbDateMadeYear1.getSelectedItem().toString());
        cbbDateMadeDay1.setModel(pika.getDayByMonth(month, year));
    }//GEN-LAST:event_cbbDateMadeMonth1ItemStateChanged

    private void cbbDateMadeYear1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeYear1ItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbDateMadeMonth1.getSelectedItem().toString());
        int year = Integer.parseInt(cbbDateMadeYear1.getSelectedItem().toString());
        cbbDateMadeDay1.setModel(pika.getDayByMonth(month, year));
    }//GEN-LAST:event_cbbDateMadeYear1ItemStateChanged

    private void cbbDateMadeMonth2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeMonth2ItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbDateMadeMonth2.getSelectedItem().toString());
        int year = Integer.parseInt(cbbDateMadeYear2.getSelectedItem().toString());
        cbbDateMadeDay2.setModel(pika.getDayByMonth(month, year));
    }//GEN-LAST:event_cbbDateMadeMonth2ItemStateChanged

    private void cbbDateMadeYear2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbDateMadeYear2ItemStateChanged
        // TODO add your handling code here:
        PikaDate pika = new PikaDate();
        int month = Integer.parseInt(cbbDateMadeMonth2.getSelectedItem().toString());
        int year = Integer.parseInt(cbbDateMadeYear2.getSelectedItem().toString());
        cbbDateMadeDay2.setModel(pika.getDayByMonth(month, year));
    }//GEN-LAST:event_cbbDateMadeYear2ItemStateChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                SearchReportMore dialog = new SearchReportMore(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    /**
     * Đây là list chứa chuỗi tìm kiếm
     */
    private ArrayList<String> list = new ArrayList<String>();

    /**
     * Method này trả về list chuỗi tìm kiếm
     * @return list chuỗi tìm kiếm
     */
    public ArrayList<String> getList() {
        return list;
    }

    private DBManagerment db = new DBManagerment();
    private Connection conn;


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup btgPaid;
    private javax.swing.JCheckBox cbDateMade;
    private javax.swing.JCheckBox cbDoctorID;
    private javax.swing.JCheckBox cbPatientID;
    private javax.swing.JCheckBox cbTest;
    private javax.swing.JComboBox cbbDateMadeDay1;
    private javax.swing.JComboBox cbbDateMadeDay2;
    private javax.swing.JComboBox cbbDateMadeMonth1;
    private javax.swing.JComboBox cbbDateMadeMonth2;
    private javax.swing.JComboBox cbbDateMadeThan1;
    private javax.swing.JComboBox cbbDateMadeThan2;
    private javax.swing.JComboBox cbbDateMadeYear1;
    private javax.swing.JComboBox cbbDateMadeYear2;
    private javax.swing.JComboBox cbbTest;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel pnlBootom;
    private javax.swing.JPanel pnlCenter;
    private javax.swing.JTextField txtDoctorID;
    private javax.swing.JTextField txtPatientID;
    // End of variables declaration//GEN-END:variables

}
